package com.sh.data.engine.application.model.mapper.integration;

import com.sh.data.engine.application.model.request.integration.*;
import com.sh.data.engine.common.enumDefinition.DSType;
import com.sh.data.engine.domain.integration.datasource.model.param.*;
import org.springframework.stereotype.Service;

@Service
public interface DataSourceCreateParamMapper {
    DataSourceSaveParam requestToParam(DataSourceCreateRequest request);

    DataSourceRdbmsSaveParam requestToCreateRdbmsParam(DataSourceCreateRequest request);

    DataSourceHiveSaveParam requestToCreateHiveParam(DataSourceCreateRequest request);

    DataSourceMongoSaveParam requestToCreateMongoParam(DataSourceCreateRequest request);

    DataSourceHDFSSaveParam requestToCreateHDFSParam(DataSourceCreateRequest request);

    DataSourceIotDBSaveParam requestToCreateIotDBParam(DataSourceCreateRequest request);

    DataSourceInfluxDBSaveParam requestToCreateInfluxDBParam(DataSourceCreateRequest request);

    default DataSourceSaveParam map(DataSourceCreateRequest request) {
        if (request == null) {
            return requestToParam(request);
        }

        if (DSType.isRdbms(request.getDsType().name())) {
            return requestToCreateRdbmsParam(request);
        } else if (request.getDsType() == DSType.Hive) {
            return requestToCreateHiveParam((request));
        } else if (request.getDsType() == DSType.Mongodb) {
            return requestToCreateMongoParam(request);
        } else if (request.getDsType() == DSType.HDFS) {
            return requestToCreateHDFSParam(request);
        } else if (request.getDsType() == DSType.IoTDB) {
            return requestToCreateIotDBParam(request);
        } else if (request.getDsType() == DSType.InfluxDB) {
            return requestToCreateInfluxDBParam(request);
        } else {
            return requestToParam(request);
        }
    }
}
